package com.google.code.p.odbcconnectionchecker.UI;

import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.BoxLayout;
import javax.swing.JTable;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JScrollPane;

public class ConnectionStatusWindow extends JFrame {

	private JPanel contentPane;
	private JTable tblStatus;
	
	/**
	 * Create the frame.
	 */
	public ConnectionStatusWindow(String[] tableHeader, String[][] tableData) {
		
		setVisible(true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new BorderLayout(0, 0));
		
		JPanel pnlButtons = new JPanel();
		contentPane.add(pnlButtons, BorderLayout.SOUTH);
		pnlButtons.setLayout(new BoxLayout(pnlButtons, BoxLayout.X_AXIS));
		
		JButton btnClose = new JButton("Close");
		btnClose.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				ConnectionStatusWindow.this.dispose();
			}
		});
		pnlButtons.add(btnClose);
		
		JLabel lblConnectionName = new JLabel("Connection Historical Status");
		lblConnectionName.setHorizontalAlignment(JLabel.CENTER);
		contentPane.add(lblConnectionName, BorderLayout.NORTH);
		
		tblStatus = new JTable(tableData, tableHeader);
		tblStatus.setRowSelectionAllowed(false);
		
		JScrollPane scrollPane = new JScrollPane(tblStatus);
		contentPane.add(scrollPane, BorderLayout.CENTER);
		
				
	}

}
